Skip to content

Phase 3 polish: journal validation, CRUD, time filters, agent robustness#3

Merged
1816x merged 1 commit into
mainfrom
claude/fase-3-trade-journal-cqcub2
Jul 18, 2026
Merged

Phase 3 polish: journal validation, CRUD, time filters, agent robustness#3
1816x merged 1 commit into
mainfrom
claude/fase-3-trade-journal-cqcub2

Conversation

@1816x

@1816x 1816x commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Follow-up to the merged Phase 3 (#2), hardening the trade journal + behavioral agent so Phases 1–3 are solid before the Phase 4 dashboard. No Rust changes.

What changed

  • Input validation on journal writes (JournalEntryIn / new JournalEntryPatch): side ∈ {long, short}, positive size/entry_price/entered_at_ns, and exited_at_ns ≥ entered_at_ns — invalid bodies now return 422 instead of being silently stored.
  • Full journal CRUD: GET/PATCH/DELETE /journal/{id} plus journal.get_entry / update_entry / delete_entry (partial updates never touch id/created_at_ns). Rounds the journal out as a real resource for the Phase 4 dashboard.
  • Time-range filters: since_ns (inclusive) / until_ns (exclusive) on GET /journal and POST /journal/analyze, to scope analysis to a session/day.
  • Agent robustness: messages.parse().parsed_output is Optional (it's None on a safety refusal or an empty structured parse). coach.analyze now raises AnalysisUnavailable, and /journal/analyze maps it to a 502 instead of a 500 on a null body.
  • End-to-end verification: scripts/verify_pipeline.sh runs the real pipeline keyless (tape → Rust engine → metrics.db → journal seed → regime join). A hermetic test_integration.py exercises the HTTP flow in CI.
  • Docs: nanosecond timestamps exceed JS's safe-integer range (~9e15); documented as a Phase 4 dashboard concern (read *_ns as string/BigInt) rather than changing the Phase 1–2 contract now.

Verification

  • cd backtest && ruff check . && ruff format --check . && pytest65 passed, lint clean.
  • cd engine && cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test10 passed, clean (confirms Phase 1–2 still green).
  • bash scripts/verify_pipeline.sh → 5000 ticks → 501 buckets → 12/12 journal entries joined to a regime.

🤖 Generated with Claude Code

Follow-up to the merged Phase 3 (PR #2), hardening the trade journal and agent:

- Input validation on POST/PATCH journal bodies (side long/short, positive
  size/price/timestamps, exited_at_ns >= entered_at_ns) -> 422 on bad input.
- Full journal CRUD: GET/PATCH/DELETE /journal/{id} plus journal.get_entry/
  update_entry/delete_entry.
- Time-range filters (since_ns/until_ns) on GET /journal and /journal/analyze.
- Agent robustness: coach.analyze raises AnalysisUnavailable when the model
  returns no structured output (refusal or empty parse); the endpoint maps it
  to 502 instead of a 500 on a null body.
- scripts/verify_pipeline.sh: keyless end-to-end smoke (tape -> engine ->
  metrics.db -> journal -> regime join). Hermetic test_integration.py covers
  the HTTP flow in CI.
- Document the nanosecond/JSON safe-integer caveat as a Phase 4 dashboard concern.
- Tests for all of the above; README updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DcbYTwtqmAgEkcTtJtsztt
@1816x
1816x merged commit 1597670 into main Jul 18, 2026
2 checks passed
@1816x
1816x deleted the claude/fase-3-trade-journal-cqcub2 branch July 23, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants